package com.example.javanewwork.service.impl;

import com.example.javanewwork.entity.Order;
import com.example.javanewwork.mapper.OrderMapper;
import com.example.javanewwork.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class OrderServiceImpl implements OrderService {


    @Autowired
    private OrderMapper orderMapper;

    @Override
    public List<Order> findAll() {

        List<Order> orders = orderMapper.findall();

        return orders;
    }

    @Override
    public void deleteByid(int id) {
    orderMapper.deleteByid(id);

    }

    @Override
    public void modify(Order order) {
        int id = order.getId();
        String buyer = order.getBuyer();
        String deviceName = order.getDeviceName();
        int count = order.getCount();
        String totalPrice = order.getTotalPrice();
        orderMapper.modify(id,buyer,deviceName,count,totalPrice);


    }

    @Override
    public void add(Order order) {

        String buyer = order.getBuyer();
        String deviceName = order.getDeviceName();
        int count = order.getCount();
        String totalPrice = order.getTotalPrice();
        orderMapper.add(buyer,deviceName,count,totalPrice);
    }
}
